package com.java.demo;

public class StoneMaze {
    public static void main(String[] args) {
        start(4);
    }
    public static void start(int n){
        int[][] maze = new int[n][n];

        int idx = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                maze[i][j] = idx ++;
            }
        }

        printArray(maze);

        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                int randi = (int)(Math.random()*n);
                int randj = (int)(Math.random()*n);

                int temp = maze[i][j];
                maze[i][j] = maze[randi][randj];
                maze[randi][randj] = temp;
            }
        }

        printArray(maze);
    }

    public static void printArray(int[][] maze){
        for (int i = 0; i < maze.length; i++) {
            for (int j = 0; j < maze[i].length; j++) {
                System.out.print(maze[i][j] + "\t");
            }
            System.out.println();
        }
        System.out.println();
    }
}
